<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
// 网站地址
String netPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
%>
<script src="<%=basePath%>/js/jquery-1.3.1.min.js"/></script>
<script type="text/javascript"></script>
<script type="text/javascript">
	function toBackup(){
		backuping();
		$.ajax({
			url:"<%=basePath%>db/toBackup",
			type:"GET",
			async: true,
			contentType:"application/x-www-form-urlencoded; charset=utf-8",
			success:function(data){
				 var jsonobj=eval('('+data+')');
				 if(jsonobj.state==='1'){
					 notBackup();
					alert(jsonobj.result);
				 } else if(jsonobj.state==='0'){
					 notBackup();
					 alert(jsonobj.result);
				 }
			},
			 error: function(XMLHttpRequest, textStatus, errorThrown) {
				 notBackup();
				 alert("备份失败！");
		  	}
		});
	};
	function backuping(){
		$("#waitingPic").css("display","block");
		$("#backupButton").attr("disabled","disabled");
		$("#closeBackup").attr("disabled","disabled");
		$("#backupButton").attr("value","备份正在进行...");
	};
	function notBackup(){
		$("#waitingPic").css("display","none");
		$("#backupButton").attr("disabled","");
		$("#closeBackup").attr("disabled","");
		$("#backupButton").attr("value","开始备份");
	};

	function toClose(){
		parent.$.dialog.close();
	}
</script>
<!--中间部分开始-->
<div class="main">
		<div style="border:1px solid balck;margin-top:30px;">
				<p>1. 请注意，备份数据库可能花去您几分钟的时间,请耐心等待</p>
				<p>2. 数据将被备份到/var/local/backup/下，如有需要请联系管理员取回</p>
		</div>
		<div id="waitingPic" style="display:none;margin-top:10px;">
			<center>
				<img src="<%=basePath%>/images/loading.jpg"/>
			</center>
		</div>
		<div style="margin-top: 10px;">
			<center>
				<input type="button" onclick="toBackup();" value="开始备份" id="backupButton"/>
				<input type="button" onclick="toClose();" value="关闭" id="closeBackup"/>
			</center>
		</div>

</div>
